
<#include "/common/head.html"/>
    
    <table id="dg"></table>
    <div id="tb" style="padding:2px 5px;">
        <div class="wrap_search">
		        		
			        		<span class="search_item search_between">
				                <span class="item_text">日期: </span>
				                <span class="item_obj">
				                    <input class="easyui-datebox" name="_start_dt" id="_start_dt" value=""/> ～ <input class="easyui-datebox" name="_end_dt" id="_end_dt" value=""/>
				                </span>
				            </span>
		        		
			        		<span class="search_item search_between">
				                <span class="item_text">收盘价: </span>
				                <span class="item_obj">
				                    <input class="easyui-textbox" name="_start_closing_price" id="_start_closing_price" value=""/> ～ <input class="easyui-textbox" name="_end_closing_price" id="_end_closing_price" value=""/>
				                </span>
				            </span>
		        		
			        		<span class="search_item search_between">
				                <span class="item_text">最高价: </span>
				                <span class="item_obj">
				                    <input class="easyui-textbox" name="_start_top_price" id="_start_top_price" value=""/> ～ <input class="easyui-textbox" name="_end_top_price" id="_end_top_price" value=""/>
				                </span>
				            </span>
		        		
			        		<span class="search_item search_between">
				                <span class="item_text">最低价: </span>
				                <span class="item_obj">
				                    <input class="easyui-textbox" name="_start_minimum_price" id="_start_minimum_price" value=""/> ～ <input class="easyui-textbox" name="_end_minimum_price" id="_end_minimum_price" value=""/>
				                </span>
				            </span>
        </div>
        <div style="text-align: left; margin:6px;">
            <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-plus" plain="true" onclick="add()">增加</a>
            <a href="javascript:void(0)" class="easyui-linkbutton updateBtn" iconCls="glyphicon-pencil" plain="true" onclick="update()">编辑</a>
            <a href="javascript:void(0)" class="easyui-linkbutton delBtn" iconCls="glyphicon-remove" plain="true" onclick="del()">删除</a>
            <a href="javascript:void(0)" class="easyui-linkbutton detailBtn" iconCls="glyphicon-map-marker" plain="true" onclick="detail()">详情</a>
            <a href="javascript:void(0)" class="easyui-linkbutton detailBtn" iconCls="glyphicon-export" plain="true" onclick="exportCsv()">导出</a>
            <div id="searchBtnWrap" style="float:right; padding-right:40px;">
                <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="glyphicon-search" onclick="zcurdSearch(this)">搜索</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="glyphicon-repeat" onclick="flushPage()">重置</a>
            </div>
        </div>
    </div>
    

<script type="text/javascript">
var datagrid = $("#dg");

var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
        rownumbers:true,
    	url:'listData',
    	method:'post',
    	toolbar:'#tb',
    	pageSize: 20,
    	pagination:true,
    	multiSort:true,
        queryParams: getInitParam(),
        
        columns: [[
		         {field:'id', checkbox:true}
	           	 ,{field:'dt', title: '日期', width:120, sortable: true}
	           	 ,{field:'code', title: '股票代码', width:120, sortable: true}
	           	 ,{field:'name', title: '名称', width:120, sortable: true}
	           	 ,{field:'closing_price', title: '收盘价', width:120, sortable: true}
	           	 ,{field:'top_price', title: '最高价', width:120, sortable: true}
	           	 ,{field:'minimum_price', title: '最低价', width:120, sortable: true}
	           	 ,{field:'opening_price', title: '开盘价', width:120, sortable: true}
	           	 ,{field:'pre', title: '前收盘', width:120, sortable: true}
	           	 ,{field:'change_amount', title: '涨跌额', width:120, sortable: true}
	           	 ,{field:'change_ratio', title: '涨跌幅', width:120, sortable: true}
	           	 ,{field:'turnover_volume', title: '成交量', width:120, sortable: true}
	           	 ,{field:'turnover_money', title: '成交金额', width:120, sortable: true}
	           	 ,{field:'create_time', title: '创建时间', width:120, sortable: true}
	           ]]
	};
$(function() {
	handleAuthDataRule();
	datagrid.datagrid(dgOptions);
});

function zcurdSearch() {
	var param = zcurdGetParam();
	datagrid.datagrid("load", {
		queryParams: param
	})
}

function zcurdGetParam() {
	var param = {};
	$("#tb :input[name]").each(function(i, item) {
		if($(item).val()) {
			param[$(item).attr("name")] = $(item).val();	
		}
	});
	return param;
}

function getInitParam() {
	var param = {};
	$("#tb :input[name]").each(function(i, item) {
		if($(item).val()) {
			param["queryParams[" + $(item).attr("name") + "]"] = $(item).val();	
		}
	});
	return param;
}

var initPara = zcurdGetParam();
function add() {
	top.window.subPage.loadCurrDatagrid = function() {
		showMsg("增加成功！");
		datagrid.datagrid("load");
	}
	top.openWindow("股票历史数据-增加", getCurrUrl("addPage") + "?" + $.param(initPara), {size: '600x400'});
}

function update() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择需要编辑的一条数据！");
		return;
	}
	var id = rowsSel[0].id;
	top.window.subPage.loadCurrDatagrid = function() {
		showMsg("更新成功！");
		datagrid.datagrid("reload");
	}
	top.openWindow("股票历史数据-编辑", getCurrUrl("updatePage") + "?id=" + id, {size: '600x400'});
}

function del() {
	var ids = [];
	$.each(datagrid.datagrid("getSelections"), function(i, item) {
		ids.push(item.id);
	});
	if(ids.length < 1) {
		showWarnMsg("请选择需要删除的数据！");
		return;
	}
	confirmMsg("确认删除？", function() {
		$.post("delete", {id: ids}, function(data) {
			showMsg("删除成功！");
			datagrid.datagrid("reload");
		});
	});
}

function detail() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择需要查看的一条数据！");
		return;
	}
	var id = rowsSel[0].id;
	top.openWindow("股票历史数据-详情", getCurrUrl("detailPage") + "?id=" + id, {size: '600x400'});
}

function exportCsv() {
	var option = datagrid.datagrid("options");
	var param = option.queryParams;
	param.sortName = option.sortName;
	param.sortOrder = option.sortOrder;
	window.location.href = "exportCsv?" + $.param(param);
}

//按钮事件

/**
 * 打开子页
 */
var _openSubPageFlag = false;
function _openSubPage(pageUrl) {
	if(!_openSubPageFlag) {
		$("#subLayout").layout("expand", "east");
		setTimeout(function() {
			$("#subIframe").attr("src", pageUrl);
		}, 600);
		_openSubPageFlag = true;
	}else {
		$("#subIframe").attr("src", pageUrl);
	}
}

//扩展js
</script>

<#include "/common/dialogWindow.html"/>
<#include "/common/foot.html"/>
